package com.sh.深浅拷贝;

class Person {
    String name;
    Address address;

    Person(String name, Address address) {
        this.name = name;
        this.address = address;
    }

    // 浅拷贝
    Person shallowCopy() {
        return new Person(this.name, this.address);
    }

    // 深拷贝
    Person deepCopy() {
        return new Person(this.name, new Address(this.address.city));
    }
}